var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = t("Platforms"),
    r = (function () {
        function t() {
            var t = this;
            this.count = function () {
                var e = new Date().getTime(),
                    o = e - t.lastTime;
                if ((o > 0 ? (o /= 1e3) : (o = 0), (t.lastTime = e), (t.restSec -= o), t.restSec <= 0)) {
                    t.restSec = 0;
                    var n = t.onComplete;
                    t.stop(), n && n();
                }
                t.setSec && t.setSec(Math.ceil(t.restSec));
            };
        }
        return (
            (t.prototype.init = function (t, e) {
                this.stop(), (this.sec = t), (this.setSec = e), this.setSec && this.setSec(this.sec);
            }),
            (t.prototype.start = function (t, e) {
                void 0 === e && (e = 0),
                    this.stop(),
                    (this.running = !0),
                    (this.onComplete = t),
                    (this.restSec = this.sec),
                    this.resume(e),
                    this.count();
            }),
            (t.prototype.pause = function () {
                this.running && ((this.counting = !1), n.default.enterFrames.clear(this.count));
            }),
            (t.prototype.resume = function (t) {
                void 0 === t && (t = 0),
                    this.running &&
                        ((this.counting = !0),
                        (this.lastTime = t > 0 ? t : new Date().getTime()),
                        n.default.enterFrames.add(this.count));
            }),
            (t.prototype.stop = function () {
                this.pause(), (this.onComplete = null), (this.running = !1);
            }),
            (t.prototype.clear = function () {
                this.stop(), (this.setSec = null);
            }),
            t
        );
    })();
o.default = r;
